/*************************************************************************
 * AUTHOR		 : Chris Hayes
 * STUDENT ID	 : 656960
 * ASSIGNMENT #5 : Multi-Dimensional Array - Tic Tac Toe
 * CLASS		 : CS1B
 * SECTION		 : MW12:30
 * DUE DATE		 : June 15, 2011
 *************************************************************************/

#include "tictacheader.h"

/**************************************************************************
* FUNCTION ComputerEasy
*__________________________________________________________________________
* This is a very simple AI.  It randomly pics a row and a column and then
* 	checks the board to see if that location has been used.  If it has,
* 	it picks another two numbers randomly until it finds an open space.
* 	This function is used in GetAndCheckInput if a player is named computer
*__________________________________________________________________________
* PRE-CONDITIONS
*  row	 : Row should be previously defined
*  col	 : Col should be previously defined
*  board : board should be previously defined
*
* POST-CONDITIONS
*  It returns a row and column to be played in GetAndCheckInput
**************************************************************************/

void ComputerEasy(int& row, int& col, const char board[][3])
{
	bool invalid;

	do
	{
		invalid = false;

		//randomly pick a row and column
		row = rand() % 3;
		col = rand() % 3;

		//
		if(!isspace(board[row][col]))
		{
			invalid = true;
		}

	}while(invalid);
}
